home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 8 / Eagles_Nest_Mac_Collection_Disc_8.TOAST / Developer Tools⁄Additions / MacUserProj / MacUser Projects / June / 2GenApp Src / AboutBox.c next >
Encoding:
C/C++ Source or Header  |  1990-04-25  |  3.9 KB  |  167 lines  |  [TEXT/KAHL]

  1. /* *****************************************************************************
  2.     FILE:             AboutBox.c
  3.     
  4.     DESCRIPTION:     AboutBox utilities
  5.  
  6.     AUTHOR:            Kurt W.G. Matthies
  7.         
  8.     Copyright © 1990 by Code of the West, Inc. All Rights Reserved.
  9.  
  10.     
  11.     Revision History:
  12.     ==========================================================
  13.     4.24.90 -     June 1990 MacUser Release - no new code
  14.     3.30.90    -    May 1990 MacUser Release
  15.     ==========================================================
  16.  
  17.    ***************************************************************************** */
  18. #include "Version.h"
  19.  
  20. #ifdef V4
  21. #include <stdio.h>
  22. #endif
  23.  
  24. #ifdef V3
  25. #include <Proto.h>
  26. #endif
  27.  
  28. #ifdef V2
  29. #include <Proto.h>
  30. #include <Pascal.h>
  31. #endif
  32.  
  33. #include "AppConstants.h"
  34. #include "StrRsrcDefs.h"
  35.  
  36. #include "DialogUtilPr.h"
  37. #include "WindowUtilPr.h"
  38.  
  39. #include "AboutBoxPr.h"
  40.  
  41. /* ---------------------------  Local Prototypes  ----------------------------- */
  42.  
  43. DialogPtr    drawAboutBox ( Boolean );
  44.  
  45. /* ----------------------------------------------------------------------------
  46.     doAboutBox -    put up about box, wait for user to go away
  47.     3.30.90kwgm
  48. ------------------------------------------------------------------------------- */
  49. void 
  50. doAboutBox ()
  51. {
  52.     EventRecord            theEvent;
  53.     DialogPtr            theDialog;
  54.     GrafPtr                savePort;
  55.     
  56.     GetPort (&savePort);
  57.  
  58.     if (theDialog = drawAboutBox (true))
  59.     {
  60.         /* wait for a key or mouse down */
  61.         while (!GetNextEvent (keyDownMask + mDownMask, &theEvent))
  62.             SystemTask();
  63.         
  64.         DisposDialog (theDialog);
  65.     }
  66.     
  67.     SetPort (savePort);
  68.  
  69. } /* doAboutBox */
  70.  
  71. /* ----------------------------------------------------------------------------
  72.     splashScreen -    put up about box, delay, go away automatically.
  73.     3.30.90kwgm        used to introduce the program.
  74. ------------------------------------------------------------------------------- */
  75. void 
  76. splashScreen ()
  77. {
  78.     EventRecord            theEvent;
  79.     DialogPtr            theDialog;
  80.     GrafPtr                savePort;
  81.     long                ticksNow;
  82.     
  83.     GetPort (&savePort);    /* save current port */
  84.  
  85.     if (theDialog = drawAboutBox (false))
  86.     {
  87.     
  88.         Delay (120L, &ticksNow);    /* wait 2 seconds */
  89.         
  90.         DisposDialog (theDialog);
  91.     }
  92.     else
  93.     {
  94.         SysBeep (1);
  95.         ExitToShell ();        /* probably can't open resource fork! */
  96.     }
  97.     
  98.     SetPort (savePort);        /* restore saved port */
  99.  
  100. } /* splashScreen */
  101.  
  102. /* -------------------------------------------------------------------------
  103.     drawAboutBox    -    do aboutbox display
  104.     3.30.90kwgm
  105. ---------------------------------------------------------------------------- */
  106. static DialogPtr
  107. drawAboutBox (doMemSize)
  108.     Boolean                doMemSize;
  109. {
  110.     register DialogPtr    theDialog;
  111.     ControlHandle        cntlHdl;
  112.     Size                sz;
  113.     short                itemType;
  114.     Rect                memBox;
  115.     Str64                memStr, formatStr;
  116.  
  117.     /* get dialog ptr from resource file */
  118.     if (!(theDialog = GetNewDialog (kAboutBoxDLOG, 0L, -1L)))
  119.         return (0L);
  120.  
  121.     /*
  122.         dialog window is invisible so that it can be centered
  123.     */
  124.  
  125.     centerWindow (theDialog);
  126.  
  127.     /* now make it visible */
  128.     ShowHide (theDialog,true);
  129.     DrawDialog (theDialog);
  130.  
  131.     if (doMemSize)        /* print a total memory avail message in about box */
  132.     {
  133.         SetPort (theDialog);    /* set this dialog as the current grafport */
  134.  
  135.         /* memBox : where to draw string */
  136.         GetDItem (theDialog, kAboutMemBox, &itemType, &cntlHdl, &memBox);
  137.         
  138.         /* get the printf format string */
  139.         GetIndString (formatStr, kNameStrRsrc, kAboutBoxMsgStr);
  140.         PtoCstr (formatStr);
  141.         
  142.         /* create memory string */
  143.         sz = FreeMem ();
  144.         sprintf (memStr, formatStr, sz >> 10);
  145.         CtoPstr (memStr);
  146.     
  147.         /* draw string as white on black */
  148.         PenPat (white);
  149.         TextFont (1);        /* 12 pt 'appfont' (usually geneva) */
  150.         TextSize (12);
  151.         TextMode (srcBic);    /* need this mode to draw white on blcak */
  152.         
  153.         MoveTo (memBox.left, memBox.bottom - 2);
  154.         DrawString (memStr);
  155.         
  156.         PenNormal ();
  157.     }
  158.     
  159.     return (theDialog);
  160.     
  161. } /* drawAboutBox */
  162.  
  163. /* ===============================  EOF  =======================================
  164.     Copyright © 1990 by Code of the West, Inc. All Rights Reserved.
  165. ================================================================================ */
  166.  
  167.